<?php

namespace app\api\controller\haipi;

use app\common\controller\Frontend;
use app\common\model\haipi\Discuz as DiscuzModel;
use app\common\model\haipi\Forum as ForumModel;
use app\common\model\haipi\Highend as HighendModel;
use app\api\service\VipService;

class Contact extends Frontend{
    protected array $noNeedLogin = [];

    public function discuz(VipService $vipService){
        $id = $this->request->post('id');
        if(!$id){
            $this->error('缺少参数');
        }
        
        $user = $this->auth->getUser();
        $vipService->visitDiscuz($user);
        $data = DiscuzModel::where('id', $id)->field('contact')->find();
        $this->success('', $data);
    }


    public function forum(VipService $vipService){
        $id = $this->request->post('id');
        if(!$id){
            $this->error('缺少参数');
        }
        
        $user = $this->auth->getUser();
        $vipService->visitForum($user);
        $data = ForumModel::where('id', $id)->field(['contacts', 'wx','qq', 'mobile'])->find();
        $this->success('', $data);
    }


    public function highend(VipService $vipService){
        $id = $this->request->post('id');
        if(!$id){
            $this->error('缺少参数');
        }
        
        $user = $this->auth->getUser();
        $vipService->visitHighend($user);
        $data = HighendModel::where('id', $id)->field(['contacts', 'wx','qq', 'mobile'])->find();
        $this->success('', $data);
    }
}
